//
//  CarShopHeaderView.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/2.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "CarShopHeaderView.h"

@interface CarShopHeaderView()

@property (nonatomic,weak) UILabel *shopNameLab;
@property (nonatomic,weak) UIButton *checkBtn;

@end
@implementation CarShopHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        UIView *grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 10)];
        grayView.backgroundColor = RGBColor(239, 239, 244);
        [self addSubview:grayView];
        
        UIButton *checkBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 10+7.5, 25, 25)];
        [checkBtn setImage:GetImage(@"icon_select_off") forState:UIControlStateNormal];
        [checkBtn setImage:GetImage(@"icon_select_on") forState:UIControlStateSelected];
        [checkBtn addTarget:self action:@selector(checkBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        self.checkBtn = checkBtn;
        [self addSubview:checkBtn];
        
        UILabel *shopNameLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(checkBtn.frame)+10, 10+11, ScreenW-55, 20)];
        shopNameLab.textColor = [UIColor blackColor];
        shopNameLab.font = Font(15);
        shopNameLab.text = @"我是店铺>";
        self.shopNameLab = shopNameLab;
        [self addSubview:shopNameLab];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 10+39.7, ScreenW, 0.3)];
        lineView.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:lineView];
    }
    return self;
}

- (void)checkBtnClick:(UIButton *)btn
{
    btn.selected = !btn.selected;
    self.model.isSelect = btn.selected;
    if ([self.delegate respondsToSelector:@selector(carShopHeaderViewSelect:)]) {
        [self.delegate carShopHeaderViewSelect:self.model];
    }
}
- (void)setModel:(BuyCarModel *)model
{
    _model = model;
    self.shopNameLab.text = [NSString stringWithFormat:@"%@ ＞",model.shopName];
    self.checkBtn.selected = model.isSelect;
}
- (void)setIsSureSingle:(BOOL)isSureSingle
{
    _isSureSingle = isSureSingle;
    self.checkBtn.selected = YES;
    self.checkBtn.userInteractionEnabled = NO;
}

@end
